export default {
  data() {
    return {
      menu: [
        {
          name: "发布任务",
        },
        {
          name: "发布任务23333333v测试测试检查测试拆好擦2333333",
        },
        {
          name: "发布任务3",
        },
        {
          name: "发布任务4",
        },
        {
          name: "发布任务5",
        },
        {
          name: "发布任务6",
        },
        {
          name: "发布任务7",
        }
      ],
      // 选中的任务集合
      selectTasks: []
    }
  },
  methods: {
    activeBg(item) {
      for (const son of this.selectTasks) {
        if (son.name === item.name) {
          return {
            backgroundColor: "#FBE18A"
          }
        }
      }
    },
    // 选择任务
    selectTask(item) {
      let index = -1
      this.selectTasks.forEach((task, key) => {
        if (item.name === task.name) {
          index = key
        }
      })

      if (index === -1) {
        this.selectTasks.push(item)
      } else {
        this.selectTasks.splice(index, 1)
      }
      console.log(this.selectTasks, " this.selectTasks.");
    }
  }
}
